{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 第四周基础作业"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1.对连续型特征，可以用哪个函数可视化其分布？（给出你最常用的一个即可），并根据代码运行结果给出示例。\n",
    "\n",
    "个人倾向使用直方图查看单独特征分布，具体使用的是pandas的hist函数和seaborn的distplot函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "df = pd.read_csv(\"boston_housing.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x170964fa518>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEGCAYAAABmXi5tAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3dd3xU15nw8d+jUW9ISAJVVECA6UVU4xI7sQEXEjuxsePEibMhLqRsspu22Wzy7r55N2822cSJY4e4JC4x6xpjmwRjG+zYFCOB6AiEkFBDDSFUUJ3z/jEjv4ospJEY6c7Mfb6fz3w0995zZ54Dmkdnzj33HDHGoJRSKvAFWR2AUkqpsaEJXymlbEITvlJK2YQmfKWUsglN+EopZRPBVgcwkMTERJOVlWV1GEop5TcKCgrqjTFJg5XxyYSflZVFfn6+1WEopZTfEJGyocpol45SStmERwlfRFaKSJGIFIvIdwc4LiLyoPv4ARFZ4N4/TUQK+zzOi8g3vF0JpZRSQxuyS0dEHMBDwCeACmCPiGwyxhzpU2wVkOt+LAEeBpYYY4qAe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7hzlQzThK7t7HGgyxhwUkauHe7L7G8J/Ab/us/tF4CdAG64Vo5TyCZrwla0ZYypwrRc6kNtFZEWf7ftxrZUwWUT2AeFAM/BrY8wTfV7znIjswrUi0alRCl2pYdPZMpVSyiZ0lI5SStmEJnyllLIJTfhKKWUTmvCVUsomNOErpZRNaMJXSimb0ISvlFI28f8ARUMLzhd47LwAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.distplot(df['MEDV'],bins=30)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1709869b1d0>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD6CAYAAABamQdMAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAATTUlEQVR4nO3dbYxc53ne8f9VyZZlMdFLZS1UUi2VgnYjh44TbwS1boulFUdKJZj6IoCCHFCtCqKF6qotjZhKPggtQFRoobQBWn8gakEs4oplHTsi7CAxy2SiFoilkn4pJdGqiIiVKSlkXVtO1hXkrnL3wx5Wu+RSHM7Lzu6z/x9AzJznPHPOPTdmL549O3MmVYUkqS1/btIFSJJGz3CXpAYZ7pLUIMNdkhpkuEtSgwx3SWrQBcM9yWNJTid59qzxTyV5IclzSf7FgvGHkhzv1t02jqIlSe/s0j7mPA78G+DfnxlIsgXYCnyoqt5Mcl03fhOwDfgg8BeA/5zk/VX11jvt4Nprr62NGzcO9ARWih/+8IdcccUVky5jxbAfi9mPt9m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bJf8rarfBn57XNtfgZo5xTQi9mMx+/E2e7HYWPoxlj+oSpImy8sPSFKDDPcBJHksyekkzy4YuybJwSQvdrdXT7LG5ZLkhiS/n+RYkueSPNiNr9V+vCfJM0m+1fXjn3bja7IfMP+J9STfSPLlbnkt9+JEkqNJvpnkcDc2ln4Y7oN5HLj9rLFdwKGq2gQc6pbXgjlgZ1X9JHAL8EB3qYm12o83gY9V1U8DHwZuT3ILa7cfAA8CxxYsr+VeAGypqg8vePvjWPphuA+gqp4CvnfW8FZgb3d/L3DXshY1IVX1WlV9vbv/p8z/EK9n7fajqmq2W3xX969Yo/1IsgG4A/h3C4bXZC/ewVj6YbiPzlRVvQbzgQdcN+F6ll2SjcDPAE+zhvvRnYb4JnAaOFhVa7kf/xr4ZeDPFoyt1V7A/H/0X01ypPuUPoypH2N7K6TWliTrgN8E/lFV/UmSSZc0MVX1FvDhJFcBX0ryU5OuaRKS3AmcrqojSWYmXc8K8dGqejXJdcDBJN8e1448ch+dU0muB+huT0+4nmWT5F3MB/vnq+qL3fCa7ccZVfU60GP+7zNrsR8fBT6R5ATzV4b9WJLfYG32AoCqerW7PQ18ifkr6I6lH4b76BwAtnf3twNPTrCWZZP5Q/TPAceq6tcWrFqr/Xhfd8ROksuBnwe+zRrsR1U9VFUbqmoj85cg+b2q+iRrsBcASa5I8mNn7gO/ADzLmPrhh5gGkOQJYIb5q7mdAh4GfgvYD/xF4GXg7qo6+4+uzUny14H/Ahzl7fOqv8L8efe12I8PMf9HsUuYP3jaX1X/LMmfZw3244zutMynq+rOtdqLJD/B/NE6zJ8S/w9VtXtc/TDcJalBnpaRpAYZ7pLUIMNdkhpkuEtSgwx3SWqQ4S5JDTLcJalBhrskNej/AYkL87Hbj32ZAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "df[\"MEDV\"].hist()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2. 对两个连续型特征，可以用哪个函数得到这两个特征之间的相关性？根据代码运行结果，给出示例。 \n",
    "\n",
    "答：两个连续性特征关系主要依靠相关系数来个衡量。也可以使用散点图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1709872c1d0>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWYAAAD8CAYAAABErA6HAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAYWElEQVR4nO3de5QU9Z338fdHxEi8wD7rKjLDgkEMGGMQAbO7cZPoM4p4ATfZBDXecR4UczlGH3U3Z5O4N7MxGF1N2InBSE5WjMbESR6MIZrNionKRUQBUcQIw0ViNoox7KMz/d0/uiFNMzPdTVdP1xSfl6cOXVW/rt+vZM53vnzrV1WKCMzMLD32afQAzMxsVw7MZmYp48BsZpYyDsxmZinjwGxmljIOzGZmKePAbGbWA0lzJW2V9GwP+yXpVklrJa2QND6Jfh2Yzcx69i1gci/7TwNGF5ZW4OtJdOrAbGbWg4j4T+C/emkyFZgXeY8DQyQdXmu/+9Z6gHLefnWdby203QwadmKjh2Ap1PnWRtV6jGpizn5/Mur/kM90d2iLiLYqumsCNhStdxS2ba7iGLupe2A2M0urQhCuJhCX6u4XSc3JqAOzmWVLrqsve+sAhhetNwObaj2oa8xmli1dnZUvtWsHLijMzng/8HpE1FTGAGfMZpYxEbnEjiXpbuBDwCGSOoDPAwPz/cQcYAEwBVgL/B64OIl+HZjNLFtyyQXmiDinzP4AZiXWYYEDs5llS4IZc6M4MJtZtvTtxb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FboiIZ/bky4WLgTcB/1q0+XvAFFzG2Cs4MNcg8rdNng20FKbLrQS+AGwqafoD4J2STuzlWA9GxM/qNljrMxHRERG39LC7tMb854Xto3ZMlyNfU/7XiLiz6JivAY8Dr0TES/U9A2s035JtZpYyzpjNzFLGgdnMLGUcmM3MUsaB2cwsZRyYzcxSxoHZzCxlHJjNzFLmfwAnj5QSTAdQKAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#使用seaborn的heatmap函数\n",
    "data = df[['CRIM',\"MEDV\"]]\n",
    "corr = data.corr()\n",
    "sns.heatmap(corr,annot=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x1709881d1d0>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAbHElEQVR4nO3df4zb933f8ddbFBXznMR3Ws6GdbaiJDCk/nATzYdWmYbBspsqiLP4YC9BsrgQiqD+p9hiN7tOKorFDlpYmNYs/WuAkXQTEC+1a6tnpQ6mGJKMbQHiRerJVRRJ89amtk+addl8bmIx9un03h8kTyTv+yW/X/L7Jfkhnw9AuOP3yOPnviJf3w8/P83dBQAIz7p+FwAA0BkCHAACRYADQKAIcAAIFAEOAIFa38sne9/73udbtmzp5VMCQPBOnjz5E3efbD7e0wDfsmWLTpw40cunBIDgmdnfRR2nCQUAAkWAA0CgCHAACBQBDgCBIsAB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NW+ZWUnSr0s6pxE8H+6+z91vcfctkj4r6Zi7P6ARPBeSZGbXm9l7at9L+g1JP1QO54OZmC2Y2bck3anKUpCvS/qypDlJT0naLOkVSZ929+aOzqFjZv9Y0n+TdFrX2jl/X5V28FE8H7+iSkdUQZWK0FPu/hUz+wcawfNRU21C+Vfu/slRPRdm9kFVat1SpZn6P7v7H+VxPghwAAgUTSgAECgCHAACRYADQKAIcAAIFAEOAIEiwAEgUAQ4AATq/wMIRTKuLO8MHQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#使用散点图\n",
    "import matplotlib.pyplot as plt\n",
    "plt.scatter(df['MEDV'],df['CRIM'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3. 如果发现特征之间有较强的相关性，在选择线性回归模型时应该采取什么措施。\n",
    "\n",
    "两方面：（1）特征方面，使用PCA类似方法降维；（2）模型方面，使用正则项"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "4. 当采用带正则的模型以及采用随机梯度下降优化算法时，需要对输入（连续型）特征进行去量纲预处理。课程代码给出了用标准化（StandardScaler）的结果，请改成最小最大缩放（MinMaxScaler）去量纲 ，并重新训练最小二乘线性回归、岭回归、和Lasso模型。 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CRIM</th>\n",
       "      <th>ZN</th>\n",
       "      <th>INDUS</th>\n",
       "      <th>CHAS</th>\n",
       "      <th>NOX</th>\n",
       "      <th>RM</th>\n",
       "      <th>AGE</th>\n",
       "      <th>DIS</th>\n",
       "      <th>RAD</th>\n",
       "      <th>TAX</th>\n",
       "      <th>PTRATIO</th>\n",
       "      <th>B</th>\n",
       "      <th>LSTAT</th>\n",
       "      <th>MEDV</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.00632</td>\n",
       "      <td>18</td>\n",
       "      <td>2.31</td>\n",
       "      <td>0</td>\n",
       "      <td>0.538</td>\n",
       "      <td>6.575</td>\n",
       "      <td>65.2</td>\n",
       "      <td>4.0900</td>\n",
       "      <td>1</td>\n",
       "      <td>296</td>\n",
       "      <td>15</td>\n",
       "      <td>396.90</td>\n",
       "      <td>4.98</td>\n",
       "      <td>24.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.02731</td>\n",
       "      <td>0</td>\n",
       "      <td>7.07</td>\n",
       "      <td>0</td>\n",
       "      <td>0.469</td>\n",
       "      <td>6.421</td>\n",
       "      <td>78.9</td>\n",
       "      <td>4.9671</td>\n",
       "      <td>2</td>\n",
       "      <td>242</td>\n",
       "      <td>17</td>\n",
       "      <td>396.90</td>\n",
       "      <td>9.14</td>\n",
       "      <td>21.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.02729</td>\n",
       "      <td>0</td>\n",
       "      <td>7.07</td>\n",
       "      <td>0</td>\n",
       "      <td>0.469</td>\n",
       "      <td>7.185</td>\n",
       "      <td>61.1</td>\n",
       "      <td>4.9671</td>\n",
       "      <td>2</td>\n",
       "      <td>242</td>\n",
       "      <td>17</td>\n",
       "      <td>392.83</td>\n",
       "      <td>4.03</td>\n",
       "      <td>34.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.03237</td>\n",
       "      <td>0</td>\n",
       "      <td>2.18</td>\n",
       "      <td>0</td>\n",
       "      <td>0.458</td>\n",
       "      <td>6.998</td>\n",
       "      <td>45.8</td>\n",
       "      <td>6.0622</td>\n",
       "      <td>3</td>\n",
       "      <td>222</td>\n",
       "      <td>18</td>\n",
       "      <td>394.63</td>\n",
       "      <td>2.94</td>\n",
       "      <td>33.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.06905</td>\n",
       "      <td>0</td>\n",
       "      <td>2.18</td>\n",
       "      <td>0</td>\n",
       "      <td>0.458</td>\n",
       "      <td>7.147</td>\n",
       "      <td>54.2</td>\n",
       "      <td>6.0622</td>\n",
       "      <td>3</td>\n",
       "      <td>222</td>\n",
       "      <td>18</td>\n",
       "      <td>396.90</td>\n",
       "      <td>5.33</td>\n",
       "      <td>36.2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      CRIM  ZN  INDUS  CHAS    NOX     RM   AGE     DIS  RAD  TAX  PTRATIO  \\\n",
       "0  0.00632  18   2.31     0  0.538  6.575  65.2  4.0900    1  296       15   \n",
       "1  0.02731   0   7.07     0  0.469  6.421  78.9  4.9671    2  242       17   \n",
       "2  0.02729   0   7.07     0  0.469  7.185  61.1  4.9671    2  242       17   \n",
       "3  0.03237   0   2.18     0  0.458  6.998  45.8  6.0622    3  222       18   \n",
       "4  0.06905   0   2.18     0  0.458  7.147  54.2  6.0622    3  222       18   \n",
       "\n",
       "        B  LSTAT  MEDV  \n",
       "0  396.90   4.98  24.0  \n",
       "1  396.90   9.14  21.6  \n",
       "2  392.83   4.03  34.7  \n",
       "3  394.63   2.94  33.4  \n",
       "4  396.90   5.33  36.2  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import MinMaxScaler\n",
    "aa_x = MinMaxScaler()\n",
    "aa_y = MinMaxScaler()\n",
    "y = df['MEDV']  \n",
    "x = df.drop([\"MEDV\"],axis=1)\n",
    "x = aa_x.fit_transform(x)\n",
    "y = aa_y.fit_transform(y.values.reshape(-1,1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "G:\\ProgramFiles\\anaconda\\envs\\csdnLearn\\lib\\site-packages\\sklearn\\linear_model\\_coordinate_descent.py:1088: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n"
     ]
    }
   ],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "x_train,x_test,y_train,y_test = train_test_split(x,y,random_state=22,test_size=0.2)\n",
    "#普通线性回归\n",
    "from sklearn.linear_model import LinearRegression\n",
    "lr = LinearRegression()\n",
    "lr.fit(x_train,y_train)\n",
    "y_test_pred_lr = lr.predict(x_test)\n",
    "y_train_pred_lr = lr.predict(x_train)\n",
    "#岭回归\n",
    "from sklearn.linear_model import RidgeCV\n",
    "from sklearn.metrics import r2_score\n",
    "alphas = [0.01, 0.1, 1,10,100]\n",
    "ridge = RidgeCV(alphas=alphas,store_cv_values=True)\n",
    "ridge.fit(x_train,y_train)\n",
    "y_test_pred_ridge = ridge.predict(x_test)\n",
    "y_train_pred_ridge = ridge.predict(x_train)\n",
    "#LAsso\n",
    "from sklearn.linear_model import LassoCV\n",
    "lasso = LassoCV()\n",
    "lasso.fit(x_train,y_train)\n",
    "y_test_pred_lasso = lasso.predict(x_test)\n",
    "y_train_pred_lasso = lasso.predict(x_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "test result:linear--0.7654592177689736\n",
      "ridge--0.7650344363774537\n",
      "lasso--0.7651210939609832\n"
     ]
    }
   ],
   "source": [
    "print(f\"test result:linear--{r2_score(y_test,y_test_pred_lr)}\")\n",
    "print(f\"ridge--{r2_score(y_test,y_test_pred_ridge)}\")\n",
    "print(f\"lasso--{r2_score(y_test,y_test_pred_lasso)}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "train result:\n",
      "linear:0.7279327516592757\n",
      "ridge:0.727867714125779\n",
      "lasso:0.7279111130931359\n"
     ]
    }
   ],
   "source": [
    "print(\"train result:\")\n",
    "print(f\"linear:{r2_score(y_train,y_train_pred_lr)}\")\n",
    "print(f\"ridge:{r2_score(y_train,y_train_pred_ridge)}\")\n",
    "print(f\"lasso:{r2_score(y_train,y_train_pred_lasso)}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "结论：相对而言，利用MinMaxScaler进行去量纲化，最小二乘线性回归模型效果最理想。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "5、代码中给出了岭回归（RidgeCV）和Lasso（LassoCV）超参数（alpha_）调优的过程，请结合两个最佳模型以及最小二乘线性回归模型的结果，给出什么场合应该用岭回归，什么场合用Lasso，什么场合用最小二乘。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答：常规下，只要数据线性相关，LinearRegression是首选的，如果模型效果不理想再考虑其他。\n",
    "接下来考虑RidgeCV；但是如果输入特征维度很高，且是稀疏关系的话，可以考虑Lasso"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "learn",
   "language": "python",
   "name": "py3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
